home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 401-425 / disk_407 / flex / src.lzh / src / flexdef.h < prev    next >
C/C++ Source or Header  |  1990-07-14  |  29KB  |  863 lines

  1. /* flexdef - definitions file for flex */
  2.  
  3. /*-
  4.  * Copyright (c) 1990 The Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * This code is derived from software contributed to Berkeley by
  8.  * Vern Paxson.
  9.  * 
  10.  * The United States Government has rights in this work pursuant
  11.  * to contract no. DE-AC03-76SF00098 between the United States
  12.  * Department of Energy and the University of California.
  13.  *
  14.  * Redistribution and use in source and binary forms are permitted provided
  15.  * that: (1) source distributions retain this entire copyright notice and
  16.  * comment, and (2) distributions including binaries display the following
  17.  * acknowledgement:  ``This product includes software developed by the
  18.  * University of California, Berkeley and its contributors'' in the
  19.  * documentation or other materials provided with the distribution and in
  20.  * all advertising materials mentioning features or use of this software.
  21.  * Neither the name of the University nor the names of its contributors may
  22.  * be used to endorse or promote products derived from this software without
  23.  * specific prior written permission.
  24.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  25.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  26.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27.  */
  28.  
  29. /* @(#) $Header: WPL:Generators/flex-2.3/RCS/flexdef.h,v 1.2 90/07/15 01:17:09 loftus Exp $ (LBL) */
  30.  
  31. #ifndef FILE
  32. #include <stdio.h>
  33. #endif
  34.  
  35. /* always be prepared to generate an 8-bit scanner */
  36. #define FLEX_8_BIT_CHARS
  37.  
  38. #ifdef FLEX_8_BIT_CHARS
  39. #define CSIZE 256
  40. #define Char unsigned char
  41. #else
  42. #define Char char
  43. #define CSIZE 128
  44. #endif
  45.  
  46. /* size of input alphabet - should be size of ASCII set */
  47. #ifndef DEFAULT_CSIZE
  48. #define DEFAULT_CSIZE 128
  49. #endif
  50.  
  51. #ifndef PROTO
  52. #ifdef __STDC__
  53. #define PROTO(proto) proto
  54. #else
  55. #define PROTO(proto) ()
  56. #endif
  57. #endif
  58.  
  59.  
  60. #ifdef USG
  61. #define SYS_V
  62. #endif
  63.  
  64. #ifdef SYS_V
  65. #include <string.h>
  66. #else
  67.  
  68. #include <strings.h>
  69. #ifdef lint
  70. char *sprintf(); /* keep lint happy */
  71. #endif
  72. #ifdef SCO_UNIX
  73. void *memset();
  74. #else
  75. char *memset();
  76. #endif
  77. #endif
  78.  
  79. #ifdef AMIGA
  80. #define bzero(s, n) setmem((char *)(s), n, '\0')
  81. #define DEFAULT_SKELETON_FILE "s:flex.skel"
  82. #ifndef abs
  83. #define abs(x) ((x) < 0 ? -(x) : (x))
  84. #endif
  85. #else
  86. #define bzero(s, n) (void) memset((char *)(s), '\0', n)
  87. #endif
  88.  
  89. #ifdef VMS
  90. #define unlink delete
  91. #define SHORT_FILE_NAMES
  92. #endif
  93.  
  94. #ifndef AMIGA
  95. char *malloc(), *realloc();
  96. #endif
  97.  
  98.  
  99. /* maximum line length we'll have to deal with */
  100. #define MAXLINE BUFSIZ
  101.  
  102. /* maximum size of file name */
  103. #define FILENAMESIZE 1024
  104.  
  105. #ifndef min
  106. #define min(x,y) ((x) < (y) ? (x) : (y))
  107. #endif
  108. #ifndef max
  109. #define max(x,y) ((x) > (y) ? (x) : (y))
  110. #endif
  111.  
  112. #ifdef MS_DOS
  113. #ifndef abs
  114. #define abs(x) ((x) < 0 ? -(x) : (x))
  115. #endif
  116. #define SHORT_FILE_NAMES
  117. #endif
  118.  
  119. #define true 1
  120. #define false 0
  121.  
  122.  
  123. #ifndef DEFAULT_SKELETON_FILE
  124. #define DEFAULT_SKELETON_FILE "flex.skel"
  125. #endif
  126.  
  127. /* special chk[] values marking the slots taking by end-of-buffer and action
  128.  * numbers
  129.  */
  130. #define EOB_POSITION -1
  131. #define ACTION_POSITION -2
  132.  
  133. /* number of data items per line for -f output */
  134. #define NUMDATAITEMS 10
  135.  
  136. /* number of lines of data in -f output before inserting a blank line for
  137.  * readability.
  138.  */
  139. #define NUMDATALINES 10
  140.  
  141. /* transition_struct_out() definitions */
  142. #define TRANS_STRUCT_PRINT_LENGTH 15
  143.  
  144. /* returns true if an nfa state has an epsilon out-transition slot
  145.  * that can be used.  This definition is currently not used.
  146.  */
  147. #define FREE_EPSILON(state) \
  148.     (transchar[state] == SYM_EPSILON && \
  149.      trans2[state] == NO_TRANSITION && \
  150.      finalst[state] != state)
  151.  
  152. /* returns true if an nfa state has an epsilon out-transition character
  153.  * and both slots are free
  154.  */
  155. #define SUPER_FREE_EPSILON(state) \
  156.     (transchar[state] == SYM_EPSILON && \
  157.      trans1[state] == NO_TRANSITION) \
  158.  
  159. /* maximum number of NFA states that can comprise a DFA state.  It's real
  160.  * big because if there's a lot of rules, the initial state will have a
  161.  * huge epsilon closure.
  162.  */
  163. #define INITIAL_MAX_DFA_SIZE 750
  164. #define MAX_DFA_SIZE_INCREMENT 750
  165.  
  166.  
  167. /* a note on the following masks.  They are used to mark accepting numbers
  168.  * as being special.  As such, they implicitly limit the number of accepting
  169.  * numbers (i.e., rules) because if there are too many rules the rule numbers
  170.  * will overload the mask bits.  Fortunately, this limit is \large/ (0x2000 ==
  171.  * 8192) so unlikely to actually cause any problems.  A check is made in
  172.  * new_rule() to ensure that this limit is not reached.
  173.  */
  174.  
  175. /* mask to mark a trailing context accepting number */
  176. #define YY_TRAILING_MASK 0x2000
  177.  
  178. /* mask to mark the accepting number of the "head" of a trailing context rule */
  179. #define YY_TRAILING_HEAD_MASK 0x4000
  180.  
  181. /* maximum number of rules, as outlined in the above note */
  182. #define MAX_RULE (YY_TRAILING_MASK - 1)
  183.  
  184.  
  185. /* NIL must be 0.  If not, its special meaning when making equivalence classes
  186.  * (it marks the representative of a given e.c.) will be unidentifiable
  187.  */
  188. #define NIL 0
  189.  
  190. #define JAM -1    /* to mark a missing DFA transition */
  191. #define NO_TRANSITION NIL
  192. #define UNIQUE -1    /* marks a symbol as an e.c. representative */
  193. #define INFINITY -1    /* for x{5,} constructions */
  194.  
  195. #define INITIAL_MAX_CCLS 100    /* max number of unique character classes */
  196. #define MAX_CCLS_INCREMENT 100
  197.  
  198. /* size of table holding members of character classes */
  199. #define INITIAL_MAX_CCL_TBL_SIZE 500
  200. #define MAX_CCL_TBL_SIZE_INCREMENT 250
  201.  
  202. #define INITIAL_MAX_RULES 100    /* default maximum number of rules */
  203. #define MAX_RULES_INCREMENT 100
  204.  
  205. #define INITIAL_MNS 2000    /* default maximum number of nfa states */
  206. #define MNS_INCREMENT 1000    /* amount to bump above by if it's not enough */
  207.  
  208. #define INITIAL_MAX_DFAS 1000    /* default maximum number of dfa states */
  209. #define MAX_DFAS_INCREMENT 1000
  210.  
  211. #define JAMSTATE -32766    /* marks a reference to the state that always jams */
  212.  
  213. /* enough so that if it's subtracted from an NFA state number, the result
  214.  * is guaranteed to be negative
  215.  */
  216. #define MARKER_DIFFERENCE 32000
  217. #define MAXIMUM_MNS 31999
  218.  
  219. /* maximum number of nxt/chk pairs for non-templates */
  220. #define INITIAL_MAX_XPAIRS 2000
  221. #define MAX_XPAIRS_INCREMENT 2000
  222.  
  223. /* maximum number of nxt/chk pairs needed for templates */
  224. #define INITIAL_MAX_TEMPLATE_XPAIRS 2500
  225. #define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
  226.  
  227. #define SYM_EPSILON (CSIZE + 1)    /* to mark transitions on the symbol epsilon */
  228.  
  229. #define INITIAL_MAX_SCS 40    /* maximum number of start conditions */
  230. #define MAX_SCS_INCREMENT 40    /* amount to bump by if it's not enough */
  231.  
  232. #define ONE_STACK_SIZE 500    /* stack of states with only one out-transition */
  233. #define SAME_TRANS -1    /* transition is the same as "default" entry for state */
  234.  
  235. /* the following percentages are used to tune table compression:
  236.  
  237.  * the percentage the number of out-transitions a state must be of the
  238.  * number of equivalence classes in order to be considered for table
  239.  * compaction by using protos
  240.  */
  241. #define PROTO_SIZE_PERCENTAGE 15
  242.  
  243. /* the percentage the number of homogeneous out-transitions of a state
  244.  * must be of the number of total out-transitions of the state in order
  245.  * that the state's transition table is first compared with a potential 
  246.  * template of the most common out-transition instead of with the first
  247.  * proto in the proto queue
  248.  */
  249. #define CHECK_COM_PERCENTAGE 50
  250.  
  251. /* the percentage the number of differences between a state's transition
  252.  * table and the proto it was first compared with must be of the total
  253.  * number of out-transitions of the state in order to keep the first
  254.  * proto as a good match and not search any further
  255.  */
  256. #define FIRST_MATCH_DIFF_PERCENTAGE 10
  257.  
  258. /* the percentage the number of differences between a state's transition
  259.  * table and the most similar proto must be of the state's total number
  260.  * of out-transitions to use the proto as an acceptable close match
  261.  */
  262. #define ACCEPTABLE_DIFF_PERCENTAGE 50
  263.  
  264. /* the percentage the number of homogeneous out-transitions of a state
  265.  * must be of the number of total out-transitions of the state in order
  266.  * to consider making a template from the state
  267.  */
  268. #define TEMPLATE_SAME_PERCENTAGE 60
  269.  
  270. /* the percentage the number of differences between a state's transition
  271.  * table and the most similar proto must be of the state's total number
  272.  * of out-transitions to create a new proto from the state
  273.  */
  274. #define NEW_PROTO_DIFF_PERCENTAGE 20
  275.  
  276. /* the percentage the total number of out-transitions of a state must be
  277.  * of the number of equivalence classes in order to consider trying to
  278.  * fit the transition table into "holes" inside the nxt/chk table.
  279.  */
  280. #define INTERIOR_FIT_PERCENTAGE 15
  281.  
  282. /* size of region set aside to cache the complete transition table of
  283.  * protos on the proto queue to enable quick comparisons
  284.  */
  285. #define PROT_SAVE_SIZE 2000
  286.  
  287. #define MSP 50    /* maximum number of saved protos (protos on the proto queue) */
  288.  
  289. /* maximum number of out-transitions a state can have that we'll rummage
  290.  * around through the interior of the internal fast table looking for a
  291.  * spot for it
  292.  */
  293. #define MAX_XTIONS_FULL_INTERIOR_FIT 4
  294.  
  295. /* maximum number of rules which will be reported as being associated
  296.  * with a DFA state
  297.  */
  298. #define MAX_ASSOC_RULES 100
  299.  
  300. /* number that, if used to subscript an array, has a good chance of producing
  301.  * an error; should be small enough to fit into a short
  302.  */
  303. #define BAD_SUBSCRIPT -32767
  304.  
  305. /* absolute value of largest number that can be stored in a short, with a
  306.  * bit of slop thrown in for general paranoia.
  307.  */
  308. #define MAX_SHORT 32766
  309.  
  310.  
  311. /* Declarations for global variables. */
  312.  
  313. /* variables for symbol tables:
  314.  * sctbl - start-condition symbol table
  315.  * ndtbl - name-definition symbol table
  316.  * ccltab - character class text symbol table
  317.  */
  318.  
  319. struct hash_entry
  320.     {
  321.     struct hash_entry *prev, *next;
  322.     char *name;
  323.     char *str_val;
  324.     int int_val;
  325.     } ;
  326.  
  327. typedef struct hash_entry *hash_table[];
  328.  
  329. #define NAME_TABLE_HASH_SIZE 101
  330. #define START_COND_HASH_SIZE 101
  331. #define CCL_HASH_SIZE 101
  332.  
  333. extern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; 
  334. extern struct hash_entry *sctbl[START_COND_HASH_SIZE];
  335. extern struct hash_entry *ccltab[CCL_HASH_SIZE];
  336.  
  337.  
  338. /* variables for flags:
  339.  * printstats - if true (-v), dump statistics
  340.  * syntaxerror - true if a syntax error has been found
  341.  * eofseen - true if we've seen an eof in the input file
  342.  * ddebug - if true (-d), make a "debug" scanner
  343.  * trace - if true (-T), trace processing
  344.  * spprdflt - if true (-s), suppress the default rule
  345.  * interactive - if true (-I), generate an interactive scanner
  346.  * caseins - if true (-i), generate a case-insensitive scanner
  347.  * useecs - if true (-Ce flag), use equivalence classes
  348.  * fulltbl - if true (-Cf flag), don't compress the DFA state table
  349.  * usemecs - if true (-Cm flag), use meta-equivalence classes
  350.  * fullspd - if true (-F flag), use Jacobson method of table representation
  351.  * gen_line_dirs - if true (i.e., no -L flag), generate #line directives
  352.  * performance_report - if true (i.e., -p flag), generate a report relating
  353.  *   to scanner performance
  354.  * backtrack_report - if true (i.e., -b flag), generate "lex.backtrack" file
  355.  *   listing backtracking states
  356.  * csize - size of character set for the scanner we're generating;
  357.  *   128 for 7-bit chars and 256 for 8-bit
  358.  * yymore_used - if true, yymore() is used in input rules
  359.  * reject - if true, generate backtracking tables for REJECT macro
  360.  * real_reject - if true, scanner really uses REJECT (as opposed to just
  361.  *   having "reject" set for variable trailing context)
  362.  * continued_action - true if this rule's action is to "fall through" to
  363.  *   the next rule's action (i.e., the '|' action)
  364.  * yymore_really_used - has a REALLY_xxx value indicating whether a
  365.  *   %used or %notused was used with yymore()
  366.  * reject_really_used - same for REJECT
  367.  */
  368.  
  369. extern int printstats, syntaxerror, eofseen, ddebug, trace, spprdflt;
  370. extern int interactive, caseins, useecs, fulltbl, usemecs;
  371. extern int fullspd, gen_line_dirs, performance_report, backtrack_report, csize;
  372. extern int yymore_used, reject, real_reject, continued_action;
  373.  
  374. #define REALLY_NOT_DETERMINED 0
  375. #define REALLY_USED 1
  376. #define REALLY_NOT_USED 2
  377. extern int yymore_really_used, reject_really_used;
  378.  
  379.  
  380. /* variables used in the flex input routines:
  381.  * datapos - characters on current output line
  382.  * dataline - number of contiguous lines of data in current data
  383.  *    statement.  Used to generate readable -f output
  384.  * linenum - current input line number
  385.  * skelfile - the skeleton file
  386.  * yyin - input file
  387.  * temp_action_file - temporary file to hold actions
  388.  * backtrack_file - file to summarize backtracking states to
  389.  * infilename - name of input file
  390.  * action_file_name - name of the temporary file
  391.  * input_files - array holding names of input files
  392.  * num_input_files - size of input_files array
  393.  * program_name - name with which program was invoked 
  394.  */
  395.  
  396. extern int datapos, dataline, linenum;
  397. extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file;
  398. extern char *infilename;
  399. extern char *action_file_name;
  400. extern char **input_files;
  401. extern int num_input_files;
  402. extern char *program_name;
  403.  
  404.  
  405. /* variables for stack of states having only one out-transition:
  406.  * onestate - state number
  407.  * onesym - transition symbol
  408.  * onenext - target state
  409.  * onedef - default base entry
  410.  * onesp - stack pointer
  411.  */
  412.  
  413. extern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
  414. extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
  415.  
  416.  
  417. /* variables for nfa machine data:
  418.  * current_mns - current maximum on number of NFA states
  419.  * num_rules - number of the last accepting state; also is number of
  420.  *             rules created so far
  421.  * current_max_rules - current maximum number of rules
  422.  * lastnfa - last nfa state number created
  423.  * firstst - physically the first state of a fragment
  424.  * lastst - last physical state of fragment
  425.  * finalst - last logical state of fragment
  426.  * transchar - transition character
  427.  * trans1 - transition state
  428.  * trans2 - 2nd transition state for epsilons
  429.  * accptnum - accepting number
  430.  * assoc_rule - rule associated with this NFA state (or 0 if none)
  431.  * state_type - a STATE_xxx type identifying whether the state is part
  432.  *              of a normal rule, the leading state in a trailing context
  433.  *              rule (i.e., the state which marks the transition from
  434.  *              recognizing the text-to-be-matched to the beginning of
  435.  *              the trailing context), or a subsequent state in a trailing
  436.  *              context rule
  437.  * rule_type - a RULE_xxx type identifying whether this a a ho-hum
  438.  *             normal rule or one which has variable head & trailing
  439.  *             context
  440.  * rule_linenum - line number associated with rule
  441.  */
  442.  
  443. extern int current_mns, num_rules, current_max_rules, lastnfa;
  444. extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
  445. extern int *accptnum, *assoc_rule, *state_type, *rule_type, *rule_linenum;
  446.  
  447. /* different types of states; values are useful as masks, as well, for
  448.  * routines like check_trailing_context()
  449.  */
  450. #define STATE_NORMAL 0x1
  451. #define STATE_TRAILING_CONTEXT 0x2
  452.  
  453. /* global holding current type of state we're making */
  454.  
  455. extern int current_state_type;
  456.  
  457. /* different types of rules */
  458. #define RULE_NORMAL 0
  459. #define RULE_VARIABLE 1
  460.  
  461. /* true if the input rules include a rule with both variable-length head
  462.  * and trailing context, false otherwise
  463.  */
  464. extern int variable_trailing_context_rules;
  465.  
  466.  
  467. /* variables for protos:
  468.  * numtemps - number of templates created
  469.  * numprots - number of protos created
  470.  * protprev - backlink to a more-recently used proto
  471.  * protnext - forward link to a less-recently used proto
  472.  * prottbl - base/def table entry for proto
  473.  * protcomst - common state of proto
  474.  * firstprot - number of the most recently used proto
  475.  * lastprot - number of the least recently used proto
  476.  * protsave contains the entire state array for protos
  477.  */
  478.  
  479. extern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
  480. extern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
  481.  
  482.  
  483. /* variables for managing equivalence classes:
  484.  * numecs - number of equivalence classes
  485.  * nextecm - forward link of Equivalence Class members
  486.  * ecgroup - class number or backward link of EC members
  487.  * nummecs - number of meta-equivalence classes (used to compress
  488.  *   templates)
  489.  * tecfwd - forward link of meta-equivalence classes members
  490.  * tecbck - backward link of MEC's
  491.  * xlation - maps character codes to their translations, or nil if no %t table
  492.  * num_xlations - number of different xlation values
  493.  */
  494.  
  495. /* reserve enough room in the equivalence class arrays so that we
  496.  * can use the CSIZE'th element to hold equivalence class information
  497.  * for the NUL character.  Later we'll move this information into
  498.  * the 0th element.
  499.  */
  500. extern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
  501.  
  502. /* meta-equivalence classes are indexed starting at 1, so it's possible
  503.  * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1
  504.  * slots total (since the arrays are 0-based).  nextecm[] and ecgroup[]
  505.  * don't require the extra position since they're indexed from 1 .. CSIZE - 1.
  506.  */
  507. extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
  508.  
  509. extern int *xlation;
  510. extern int num_xlations;
  511.  
  512.  
  513. /* variables for start conditions:
  514.  * lastsc - last start condition created
  515.  * current_max_scs - current limit on number of start conditions
  516.  * scset - set of rules active in start condition
  517.  * scbol - set of rules active only at the beginning of line in a s.c.
  518.  * scxclu - true if start condition is exclusive
  519.  * sceof - true if start condition has EOF rule
  520.  * scname - start condition name
  521.  * actvsc - stack of active start conditions for the current rule
  522.  */
  523.  
  524. extern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc;
  525. extern char **scname;
  526.  
  527.  
  528. /* variables for dfa machine data:
  529.  * current_max_dfa_size - current maximum number of NFA states in DFA
  530.  * current_max_xpairs - current maximum number of non-template xtion pairs
  531.  * current_max_template_xpairs - current maximum number of template pairs
  532.  * current_max_dfas - current maximum number DFA states
  533.  * lastdfa - last dfa state number created
  534.  * nxt - state to enter upon reading character
  535.  * chk - check value to see if "nxt" applies
  536.  * tnxt - internal nxt table for templates
  537.  * base - offset into "nxt" for given state
  538.  * def - where to go if "chk" disallows "nxt" entry
  539.  * nultrans - NUL transition for each state
  540.  * NUL_ec - equivalence class of the NUL character
  541.  * tblend - last "nxt/chk" table entry being used
  542.  * firstfree - first empty entry in "nxt/chk" table
  543.  * dss - nfa state set for each dfa
  544.  * dfasiz - size of nfa state set for each dfa
  545.  * dfaacc - accepting set for each dfa state (or accepting number, if
  546.  *    -r is not given)
  547.  * accsiz - size of accepting set for each dfa state
  548.  * dhash - dfa state hash value
  549.  * numas - number of DFA accepting states created; note that this
  550.  *    is not necessarily the same value as num_rules, which is the analogous
  551.  *    value for the NFA
  552.  * numsnpairs - number of state/nextstate transition pairs
  553.  * jambase - position in base/def where the default jam table starts
  554.  * jamstate - state number corresponding to "jam" state
  555.  * end_of_buffer_state - end-of-buffer dfa state number
  556.  */
  557.  
  558. extern int current_max_dfa_size, current_max_xpairs;
  559. extern int current_max_template_xpairs, current_max_dfas;
  560. extern int lastdfa, lasttemp, *nxt, *chk, *tnxt;
  561. extern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz;
  562. extern union dfaacc_union
  563.     {
  564.     int *dfaacc_set;
  565.     int dfaacc_state;
  566.     } *dfaacc;
  567. extern int *accsiz, *dhash, numas;
  568. extern int numsnpairs, jambase, jamstate;
  569. extern int end_of_buffer_state;
  570.  
  571. /* variables for ccl information:
  572.  * lastccl - ccl index of the last created ccl
  573.  * current_maxccls - current limit on the maximum number of unique ccl's
  574.  * cclmap - maps a ccl index to its set pointer
  575.  * ccllen - gives the length of a ccl
  576.  * cclng - true for a given ccl if the ccl is negated
  577.  * cclreuse - counts how many times a ccl is re-used
  578.  * current_max_ccl_tbl_size - current limit on number of characters needed
  579.  *    to represent the unique ccl's
  580.  * ccltbl - holds the characters in each ccl - indexed by cclmap
  581.  */
  582.  
  583. extern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse;
  584. extern int current_max_ccl_tbl_size;
  585. extern Char *ccltbl;
  586.  
  587.  
  588. /* variables for miscellaneous information:
  589.  * starttime - real-time when we started
  590.  * endtime - real-time when we ended
  591.  * nmstr - last NAME scanned by the scanner
  592.  * sectnum - section number currently being parsed
  593.  * nummt - number of empty nxt/chk table entries
  594.  * hshcol - number of hash collisions detected by snstods
  595.  * dfaeql - number of times a newly created dfa was equal to an old one
  596.  * numeps - number of epsilon NFA states created
  597.  * eps2 - number of epsilon states which have 2 out-transitions
  598.  * num_reallocs - number of times it was necessary to realloc() a group
  599.  *          of arrays
  600.  * tmpuses - number of DFA states that chain to templates
  601.  * totnst - total number of NFA states used to make DFA states
  602.  * peakpairs - peak number of transition pairs we had to store internally
  603.  * numuniq - number of unique transitions
  604.  * numdup - number of duplicate transitions
  605.  * hshsave - number of hash collisions saved by checking number of states
  606.  * num_backtracking - number of DFA states requiring back-tracking
  607.  * bol_needed - whether scanner needs beginning-of-line recognition
  608.  */
  609.  
  610. extern char *starttime, *endtime, nmstr[MAXLINE];
  611. extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
  612. extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
  613. extern int num_backtracking, bol_needed;
  614.  
  615. void *allocate_array(), *reallocate_array();
  616.  
  617. #define allocate_integer_array(size) \
  618.     (int *) allocate_array( size, sizeof( int ) )
  619.  
  620. #define reallocate_integer_array(array,size) \
  621.     (int *) reallocate_array( (void *) array, size, sizeof( int ) )
  622.  
  623. #define allocate_int_ptr_array(size) \
  624.     (int **) allocate_array( size, sizeof( int * ) )
  625.  
  626. #define allocate_char_ptr_array(size) \
  627.     (char **) allocate_array( size, sizeof( char * ) )
  628.  
  629. #define allocate_dfaacc_union(size) \
  630.     (union dfaacc_union *) \
  631.         allocate_array( size, sizeof( union dfaacc_union ) )
  632.  
  633. #define reallocate_int_ptr_array(array,size) \
  634.     (int **) reallocate_array( (void *) array, size, sizeof( int * ) )
  635.  
  636. #define reallocate_char_ptr_array(array,size) \
  637.     (char **) reallocate_array( (void *) array, size, sizeof( char * ) )
  638.  
  639. #define reallocate_dfaacc_union(array, size) \
  640.     (union dfaacc_union *) \
  641.     reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
  642.  
  643. #define allocate_character_array(size) \
  644.     (Char *) allocate_array( size, sizeof( Char ) )
  645.  
  646. #define reallocate_character_array(array,size) \
  647.     (Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
  648.  
  649.  
  650. /* used to communicate between scanner and parser.  The type should really
  651.  * be YYSTYPE, but we can't easily get our hands on it.
  652.  */
  653. extern int yylval;
  654.  
  655.  
  656. /* external functions that are cross-referenced among the flex source files */
  657.  
  658.  
  659. /* from file ccl.c */
  660.  
  661. extern void ccladd PROTO((int, int));    /* Add a single character to a ccl */
  662. extern int cclinit PROTO(());    /* make an empty ccl */
  663. extern void cclnegate PROTO((int));    /* negate a ccl */
  664.  
  665. /* list the members of a set of characters in CCL form */
  666. extern void list_character_set PROTO((FILE*, int[]));
  667.  
  668.  
  669. /* from file dfa.c */
  670.  
  671. /* increase the maximum number of dfas */
  672. extern void increase_max_dfas PROTO(());
  673.  
  674. extern void ntod PROTO(());    /* convert a ndfa to a dfa */
  675.  
  676.  
  677. /* from file ecs.c */
  678.  
  679. /* convert character classes to set of equivalence classes */
  680. extern void ccl2ecl PROTO(());
  681.  
  682. /* associate equivalence class numbers with class members */
  683. extern int cre8ecs PROTO((int[], int[], int));
  684.  
  685. /* associate equivalence class numbers using %t table */
  686. extern int ecs_from_xlation PROTO((int[]));
  687.  
  688. /* update equivalence classes based on character class transitions */
  689. extern void mkeccl PROTO((Char[], int, int[], int[], int, int));
  690.  
  691. /* create equivalence class for single character */
  692. extern void mkechar PROTO((int, int[], int[]));
  693.  
  694.  
  695. /* from file gen.c */
  696.  
  697. extern void make_tables PROTO(());    /* generate transition tables */
  698.  
  699.  
  700. /* from file main.c */
  701.  
  702. extern void flexend PROTO((int));
  703.  
  704.  
  705. /* from file misc.c */
  706.  
  707. /* write out the actions from the temporary file to lex.yy.c */
  708. extern void action_out PROTO(());
  709.  
  710. /* true if a string is all lower case */
  711. extern int all_lower PROTO((register Char *));
  712.  
  713. /* true if a string is all upper case */
  714. extern int all_upper PROTO((register Char *));
  715.  
  716. /* bubble sort an integer array */
  717. extern void bubble PROTO((int [], int));
  718.  
  719. /* shell sort a character array */
  720. extern void cshell PROTO((Char [], int, int));
  721.  
  722. extern void dataend PROTO(());    /* finish up a block of data declarations */
  723.  
  724. /* report an error message and terminate */
  725. extern void flexerror PROTO((char[]));
  726.  
  727. /* report a fatal error message and terminate */
  728. extern void flexfatal PROTO((char[]));
  729.  
  730. /* report an error message formatted with one integer argument */
  731. extern void lerrif PROTO((char[], int));
  732.  
  733. /* report an error message formatted with one string argument */
  734. extern void lerrsf PROTO((char[], char[]));
  735.  
  736. /* spit out a "# line" statement */
  737. extern void line_directive_out PROTO((FILE*));
  738.  
  739. /* generate a data statment for a two-dimensional array */
  740. extern void mk2data PROTO((int));
  741.  
  742. extern void mkdata PROTO((int));    /* generate a data statement */
  743.  
  744. /* return the integer represented by a string of digits */
  745. extern int myctoi PROTO((Char []));
  746.  
  747. /* write out one section of the skeleton file */
  748. extern void skelout PROTO(());
  749.  
  750. /* output a yy_trans_info structure */
  751. extern void transition_struct_out PROTO((int, int));
  752.  
  753.  
  754. /* from file nfa.c */
  755.  
  756. /* add an accepting state to a machine */
  757. extern void add_accept PROTO((int, int));
  758.  
  759. /* make a given number of copies of a singleton machine */
  760. extern int copysingl PROTO((int, int));
  761.  
  762. /* debugging routine to write out an nfa */
  763. extern void dumpnfa PROTO((int));
  764.  
  765. /* finish up the processing for a rule */
  766. extern void finish_rule PROTO((int, int, int, int));
  767.  
  768. /* connect two machines together */
  769. extern int link_machines PROTO((int, int));
  770.  
  771. /* mark each "beginning" state in a machine as being a "normal" (i.e.,
  772.  * not trailing context associated) state
  773.  */
  774. extern void mark_beginning_as_normal PROTO((register int));
  775.  
  776. /* make a machine that branches to two machines */
  777. extern int mkbranch PROTO((int, int));
  778.  
  779. extern int mkclos PROTO((int));    /* convert a machine into a closure */
  780. extern int mkopt PROTO((int));    /* make a machine optional */
  781.  
  782. /* make a machine that matches either one of two machines */
  783. extern int mkor PROTO((int, int));
  784.  
  785. /* convert a machine into a positive closure */
  786. extern int mkposcl PROTO((int));
  787.  
  788. extern int mkrep PROTO((int, int, int));    /* make a replicated machine */
  789.  
  790. /* create a state with a transition on a given symbol */
  791. extern int mkstate PROTO((int));
  792.  
  793. extern void new_rule PROTO(());    /* initialize for a new rule */
  794.  
  795.  
  796. /* from file parse.y */
  797.  
  798. /* write out a message formatted with one string, pinpointing its location */
  799. extern void format_pinpoint_message PROTO((char[], char[]));
  800.  
  801. /* write out a message, pinpointing its location */
  802. extern void pinpoint_message PROTO((char[]));
  803.  
  804. extern void synerr PROTO((char []));    /* report a syntax error */
  805. extern int yyparse PROTO(());    /* the YACC parser */
  806.  
  807.  
  808. /* from file scan.l */
  809.  
  810. extern int flexscan PROTO(());    /* the Flex-generated scanner for flex */
  811.  
  812. /* open the given file (if NULL, stdin) for scanning */
  813. extern void set_input_file PROTO((char*));
  814.  
  815. extern int yywrap PROTO(());    /* wrapup a file in the lexical analyzer */
  816.  
  817.  
  818. /* from file sym.c */
  819.  
  820. /* save the text of a character class */
  821. extern void cclinstal PROTO ((Char [], int));
  822.  
  823. /* lookup the number associated with character class */
  824. extern int ccllookup PROTO((Char []));
  825.  
  826. extern void ndinstal PROTO((char[], Char[]));    /* install a name definition */
  827. extern void scinstal PROTO((char[], int));    /* make a start condition */
  828.  
  829. /* lookup the number associated with a start condition */
  830. extern int sclookup PROTO((char[]));
  831.  
  832.  
  833. /* from file tblcmp.c */
  834.  
  835. /* build table entries for dfa state */
  836. extern void bldtbl PROTO((int[], int, int, int, int));
  837.  
  838. extern void cmptmps PROTO(());    /* compress template table entries */
  839. extern void inittbl PROTO(());    /* initialize transition tables */
  840. extern void mkdeftbl PROTO(());    /* make the default, "jam" table entries */
  841.  
  842. /* create table entries for a state (or state fragment) which has
  843.  * only one out-transition */
  844. extern void mk1tbl PROTO((int, int, int, int));
  845.  
  846. /* place a state into full speed transition table */
  847. extern void place_state PROTO((int*, int, int));
  848.  
  849. /* save states with only one out-transition to be processed later */
  850. extern void stack1 PROTO((int, int, int, int));
  851.  
  852.  
  853. /* from file yylex.c */
  854.  
  855. extern int yylex PROTO(());
  856.  
  857.  
  858. /* The Unix kernel calls used here */
  859.  
  860. extern int read PROTO((int, char*, int));
  861. extern int unlink PROTO((char*));
  862. extern int write PROTO((int, char*, int));
  863.